package com.youbug.mall.coupon_sms.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.youbug.common.vo.QueryVo;
import com.youbug.mall.coupon_sms.entity.SmsSeckillSkuNotice;
import com.youbug.mall.coupon_sms.service.ISmsSeckillSkuNoticeService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 秒杀商品通知订阅 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-07-20
 */
@RestController
@RequestMapping("/smsSeckillSkuNotice")
public class SmsSeckillSkuNoticeController {
@Autowired
private ISmsSeckillSkuNoticeService smsSeckillSkuNoticeService;

    @PostMapping("/getSmsSeckillSkuNoticePage")
    public R<IPage<SmsSeckillSkuNotice>> getSmsSeckillSkuNoticePage(@RequestBody QueryVo<SmsSeckillSkuNotice> queryVo){

        IPage<SmsSeckillSkuNotice> smsSeckillSkuNotices = smsSeckillSkuNoticeService.getSmsSeckillSkuNoticePage(queryVo);

        return R.ok(smsSeckillSkuNotices);
    }

    @GetMapping("/getSmsSeckillSkuNoticeById/{id}")
    public R<SmsSeckillSkuNotice> getSmsSeckillSkuNoticeById(@PathVariable Long id){

        SmsSeckillSkuNotice smsSeckillSkuNotice = smsSeckillSkuNoticeService.getById(id);

        return R.ok(smsSeckillSkuNotice);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody SmsSeckillSkuNotice smsSeckillSkuNotice){

        boolean save = smsSeckillSkuNoticeService.save(smsSeckillSkuNotice);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody SmsSeckillSkuNotice smsSeckillSkuNotice){

        boolean update = smsSeckillSkuNoticeService.updateById(smsSeckillSkuNotice);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Long id){

        boolean remove = smsSeckillSkuNoticeService.removeById(id);

        return  R.ok(remove);
    }
}

